<?php
    require 'common.php';
    
    $db = new Database();
    $user = getUser($db);
    
    // Error check
    if($user['group'] < 1) {
        redirect('login.php');
        exit();
    }
        
    $page = new HtmlPage();
    $page->writeHeader(lang('HOME_PAGENAME'));
    $page->writeTitle();
    $page->writeMenu('HOME', $user);
    $page->write('<div class="content">', PUSH_TAB);
    
    $page->write('<h2>'.lang('BLOCK_LIST').'</h2>');
    $result = $db->query('SELECT name, id '.
        'FROM '.config('DB_PREFIX').'blocks '.
        'ORDER BY created DESC');
    $page->write('<ul>', PUSH_TAB);
    while($row = mysqli_fetch_assoc($result))
        $page->write('<li><a href="nextq.php?id='.$row['id'].'">'.
            htmlEscape($row['name']).'</a></li>');
    $page->write('</ul>', POP_TAB);
    
    $page->write('</div>', POP_TAB);
    $page->writeFooter();
?>